import axios from "axios";
import { Message } from "element-ui";
import store from "@/store";
const baseURL = 'http://121.89.205.189:3000/admin'
const request = axios.create({
  baseURL,
 
})
// 请求拦截器
request.interceptors.request.use(ax => {
  let token =store.state.login.profile.token
  ax.headers['token']=token
  // 拦截的后台返回数据再传出去
  console.log(ax);
  return ax;
},err=>{
  console.log(err);
  return err
});

// 响应拦截器
request.interceptors.response.use(
  res => {
    if(res.data.code !=200){
      Message({
        type:'error',
        message:res.data.message
      })
    }

    return res.data},
  error => {
   
    return Promise.reject(error);
  }
);
export default request